﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using Assist;

namespace YJKRevitStairs.HYElevator.DataInfo
{
	public class XmlConfigData
	{
		public XmlConfigData()
		{
			this.m_dicLoadToSize = new Dictionary<int, SizeAndPersonNum>();
			this.m_lstRateSpeed = new List<double>();
		}

		public Dictionary<int, SizeAndPersonNum> DicLoadToSize
		{
			get
			{
				return this.m_dicLoadToSize;
			}
		}

		public ElevatorType ElevatorType
		{
			get
			{
				return this.m_elevatorType;
			}
		}

		public List<DoorType> LstDoorType
		{
			get
			{
				return this.m_lstDoorType;
			}
		}

		public List<double> lstRatedSpeed
		{
			get
			{
				return this.m_lstRateSpeed;
			}
		}

		public static List<XmlConfigData> ReadXmlData()
		{
			string filename = string.Empty;
			filename = AssistFunc.GetAppRootPath() + "\\Data" + "\\ElevatorType.xml";
			List<XmlConfigData> list = new List<XmlConfigData>();
			try
			{
				XmlDocument xmlDocument = new XmlDocument();
				xmlDocument.Load(filename);
				XmlNode documentElement = xmlDocument.DocumentElement;
				if (documentElement != null)
				{
					IEnumerator enumerator = documentElement.ChildNodes.GetEnumerator();
					{
						while (enumerator.MoveNext())
						{
							object obj = enumerator.Current;
							XmlNode xmlNode = (XmlNode)obj;
							XmlConfigData xmlConfigData = new XmlConfigData();
							string value = xmlNode.Attributes["name"].Value;
							xmlConfigData.m_elevatorType = MatchType.GetElevatorType(value);
							XmlNodeList childNodes = xmlNode.ChildNodes;
							if (childNodes.Count != 3)
							{
								return null;
							}
							foreach (object obj2 in childNodes[0].ChildNodes)
							{
								XmlNode xmlNode2 = (XmlNode)obj2;
								int key = Convert.ToInt32(xmlNode2.Attributes["name"].Value);
								XmlNodeList childNodes2 = xmlNode2.ChildNodes;
								SizeAndPersonNum sizeAndPersonNum = new SizeAndPersonNum();
								sizeAndPersonNum.m_nPersonNum = Convert.ToInt32(childNodes2[0].InnerText);
								sizeAndPersonNum.m_nCarWidth = Convert.ToInt32(childNodes2[1].InnerText);
								sizeAndPersonNum.m_nCarDepth = Convert.ToInt32(childNodes2[2].InnerText);
								sizeAndPersonNum.m_nCarHeight = Convert.ToInt32(childNodes2[3].InnerText);
								sizeAndPersonNum.m_nDoorWidth = Convert.ToInt32(childNodes2[4].InnerText);
								sizeAndPersonNum.m_nDoorHeight = Convert.ToInt32(childNodes2[5].InnerText);
								xmlConfigData.m_dicLoadToSize.Add(key, sizeAndPersonNum);
							}
							XmlNode xmlNode3 = childNodes[1];
							List<double> list2 = new List<double>();
							foreach (object obj3 in xmlNode3.ChildNodes)
							{
								XmlNode xmlNode4 = (XmlNode)obj3;
								list2.Add(Convert.ToDouble(xmlNode4.Attributes["name"].Value));
							}
							xmlConfigData.m_lstRateSpeed = list2;
							XmlNode xmlNode5 = childNodes[2];
							List<DoorType> list3 = new List<DoorType>();
							foreach (object obj4 in xmlNode5)
							{
								XmlNode xmlNode6 = (XmlNode)obj4;
								list3.Add(MatchType.GetDoorType(xmlNode6.Attributes["name"].Value));
							}
							xmlConfigData.m_lstDoorType = list3;
							list.Add(xmlConfigData);
						}
						goto IL_2CC;
					}
					goto IL_2C7;
					IL_2CC:
					return list;
				}
				IL_2C7:
				return null;
			}
			catch (Exception)
			{
				return null;
			}
			return list;
		}

		private Dictionary<int, SizeAndPersonNum> m_dicLoadToSize;

		private ElevatorType m_elevatorType;

		private List<DoorType> m_lstDoorType;

		private List<double> m_lstRateSpeed;
	}
}
